# -----------------------------------------------------------------
# Licensed Materials - Property of IBM
#
# 5725-M82 - IBM Presence Zones
#
# (c) Copyright IBM Corp. 2013, 2014
#
# All rights reserved.
# US Government Users Restricted Rights - Use, duplication or
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
# -----------------------------------------------------------------

# -----------------------------------------------------------------
# Licensed Materials - Property of IBM

# (c) Copyright IBM Corp. 2013, 2014
#
# All rights reserved.
# US Government Users Restricted Rights - Use, duplication or
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
# -----------------------------------------------------------------

# Process command line arguments
args=($@)   

appserverIP=${args[0]}
buildlabel=${args[1]}

restAutomationConfig=/root/restAutomation/$buildlabel/Rest_Automation_Test/resources/restAssured.config
restAutomationScript=/root/restAutomation/$buildlabel/Rest_Automation_Test
restAutomationDirectory=/root/restAutomation/$buildlabel/ruby-gem/depac-automation
restAutomationResult=/root/restAutomation/$buildlabel/Rest_Automation_Test/result

echo "start to launch rest automation......"

echo "#1.Delete old IP address on Auto testing server"
sudo sed -i /BASEURI/d  $restAutomationConfig

echo "#2.Add new IP address on Auto testing server"
sudo sed -i '$ a\\BASEURI=http://'$appserverIP'' $restAutomationConfig

echo "#3.Launch Auto testing on #{appserverIP}"

echo "#3.1 redirectiry to $restAutomationDirectory"
cd $restAutomationDirectory

echo "#3.2 launch command runRestAutomation $restAutomationScript $buildlabel"
runRestAutomation $restAutomationScript $buildlabel

echo "finish to launch rest automation......"
